<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        window.onload=function(){
          var oUl=document.getElementById('ul1');
          var aLi=oUl.getElementsByTagName('li');
          for(var i=0;i<aLi.length;i++){//遍历所有的li

              if(aLi[i].className=='box'){//判断li的className是否等会box，找到样式为box的标签
                  aLi[i].style.background='red';
              }
          }
        };
    </script>
</head>
<body>
<ul id="ul1">
    <li class="box"></li>
    <li></li>
    <li></li>
    <li class="box"></li>
    <li></li>
    <li class="box"></li>
</ul>
</body>
</html>